package leetCode.offer57;


import java.util.HashMap;
import java.util.Map;

public class Solution1 implements Solution{

    @Override
    public int[] twoSum(int[] nums, int target) {
        int[] result = new int[2];
        Map<Integer, Integer> map = new HashMap<>();
        for(int i=0;i<nums.length;i++){
            map.put(target-nums[i],nums[i]);
        }
        for(int num:nums){
            if(map.containsKey(num)){
                result[0] = num;
                result[1] = target-num;
            }
        }
        return result;
    }
}
